<!--发布成果-->
<template>
    <view class="ma-24">
        <view v-if="loading" class="flex flex-row flex-row-center-center px-50 py-24">
            <tm-icon spin name="tmicon-shuaxin"></tm-icon>
        </view>

        <view v-else>
            <view v-if="subdata.id!=''&&subdata?.examine_data" class="mb-12 white round-5 c_yy">
                <tm-input 
                    :disabled="true"
                    transprent prefixLabel="当前状态" :margin="[0, 10]" :padding="[0, 0]"
                    :model-value="subdata?.examine_data.text"
                    :font-color="subdata?.examine_data.color"
                    :input-padding="[24, 0]" :height="88" :round="5" align="right" placeholder="">
                </tm-input>
            </view>
            
            <view class="mb-12 white round-5 c_yy">
                <view class="px-24 pt-18 pb-29">
                    <view class="text-size-m">标题</view>
                    <view class="mt-19">
                        <tm-input v-model="subdata.title" type="textarea" :margin="[0, 10]" :padding="[0, 0]"
                            :input-padding="[24, 24]" :height="128" :round="5" placeholder="请填写">
                        </tm-input>
                    </view>
                </view>
            </view>


            <picker-cell title="投资方式" v-model:id="subdata.type_id" :list="filterList?.type_id"
                v-if="filterList?.type_id?.length > 0"></picker-cell>
			<picker-cell title="行业类型" v-model:id="subdata.industry_id" :list="filterList?.industry_id"
			v-if="filterList?.industry_id?.length > 0"></picker-cell>

            <view class="mb-12 white round-5 c_yy">
                <tm-input v-model="subdata.amount" transprent prefixLabel="投资金额" :margin="[0, 10]" :padding="[0, 0]"
                    :input-padding="[24, 0]" :height="88" :round="5" align="right" placeholder="请输入信息">
                </tm-input>
            </view>

     


            <view class="mb-12 white round-5 c_yy">
                <tm-input v-model="subdata.name" transprent prefixLabel="联系人姓名" :margin="[0, 10]" :padding="[0, 0]"
                    :input-padding="[24, 0]" :height="88" :round="5" align="right" placeholder="请输入信息">
                </tm-input>
            </view>
            <view class="mb-12 white round-5 c_yy">
                <tm-input v-model="subdata.phone" transprent prefixLabel="联系人电话" :margin="[0, 10]" :padding="[0, 0]"
                    :input-padding="[24, 0]" :height="88" :round="5" align="right" placeholder="请输入信息">
                </tm-input>
            </view>

            <view class="mb-12 white round-5 c_yy">
                <tm-input v-model="subdata.email" transprent prefixLabel="联系人邮箱" :margin="[0, 10]" :padding="[0, 0]"
                    :input-padding="[24, 0]" :height="88" :round="5" align="right" placeholder="请输入信息">
                </tm-input>
            </view>

            <view class="mb-12 white round-5 c_yy">
                <view class="px-24 pt-18 pb-29">
                    <view class="text-size-m">简介</view>
                    <view class="mt-19">
                        <tm-input v-model="subdata.intro" type="textarea" :margin="[0, 10]" :padding="[0, 0]"
                            :input-padding="[24, 24]" :height="428" :round="5" placeholder="请填写">
                        </tm-input>
                    </view>
                </view>
            </view>


            <view class="mx-24 mt-24">
                <tm-button @click="contentAddComment" block :round="3" label="发布投资"></tm-button>
            </view>
        </view>
    </view>
</template>

<script lang="ts" setup>
import { ref } from "vue"
import { apiUr } from "@/libs/api";
import { onMounted } from "vue";
import pickerCell from "./picker-cell.vue";
const filterList = ref<{ [key: string]: any }>({})
const props = defineProps({
    id: {
        type: [String, Number],
        default: ""
    }
})
const loading = ref(true)



const subdata = ref({

    id: "",
	intro: "",//简介
	title: "",//标题,
    email: "",//联系人邮箱
    name: "",//联系人姓名
    phone: "",//联系人电话

	type_id:"",//成果类型
	industry_id: "",//行业类型,
	amount: "",//投资金额


    type: "investment"
})


onMounted(async () => {
    await getaddPageData()
    await getDetail();
    loading.value = false;
})

async function getaddPageData() {
    uni.showLoading({ title: "...", mask: true })
    let rqd = await apiUr.getaddPageData("investment");
    filterList.value = rqd.data;
}

async function contentAddComment() {
    uni.showLoading({ title: "...", mask: true })
    await apiUr.contentAdd(subdata.value);
    uni.$tm.u.setCookie("refreshFabuList","true")
    uni.showModal({
        title: "提醒",
        content: "发布成功，请选修审核，重复提交会让内容重新审核",
        showCancel: false,
        success() {
            uni.navigateBack({})
        }
    })
}
async function getDetail(){
    if(!props.id) return;
    uni.showLoading({ title: "...", mask: true })
    let data = await apiUr.contentGetCommentDetail({id:props.id,type:"investment"});
    subdata.value = {...data.data,type:"investment"}
}
</script>



<style>
page,
body {
    background-color: #FFFFFF;
}
</style>

<style lang="less" scoped>
.c_yy {
    box-shadow: 0rpx 3rpx 16rpx 0rpx rgba(0, 0, 0, 0.05);
}
</style>